import Component from "../component";

class Brand extends Component {
  brand_type: '3' | '4' | 'WECHAT_CHANNELS' | undefined = undefined;
  accountCode: string = '';

  supplement = {
    creativeTemplateId: '',
    siteSet: []
  };

  // 品牌地址
  value = {
    brand_image_id: undefined,
    brand_name: '',
    brand_url: ''
  }

  splitId(id: string | undefined) {
    if(!id) return id;
    const v = id.split('#MD');
    if (v) return v[0];
  }

  joinId(value?:any) {
    if(!value) value = this.value;
    if(!value.brand_image_id) return undefined;
    return value.brand_image_id + '#MD' + value.brand_name;
  }


  query() {
    // 如果是视频号
    if (this.brand_type === 'WECHAT_CHANNELS') {
      return {
        jump_info: {
          page_spec: {
            wechat_channels_profile_spec: {
              username: "" + this.splitId(this.value.brand_image_id)
            }
          },
          page_type: 'PAGE_TYPE_WECHAT_CHANNELS_PROFILE'
        }
      }
    }
    return {
      brand_image_id: "" + this.splitId(this.value.brand_image_id),
      brand_name: "" + this.value.brand_name,
    }
  }
}

export default Brand;
